package com.flot.yazb.widget.utils;

import java.security.MessageDigest;

public class MD5Utils {

	public static String getMd5(String pwd) {

		try {
			MessageDigest digest = MessageDigest.getInstance("md5");

			byte[] result = digest.digest(pwd.getBytes());
			StringBuffer buffer = new StringBuffer();
			for (byte b : result) {
				// 0xff是十六进制，十进制为255

				int nuber = b & 0xff;
				String str = Integer.toHexString(nuber);
				if (str.length() == 1) {
					buffer.append("0");
				}
				buffer.append(str);

			}
			// 这就是MD5加密得到的值
			return buffer.toString();

		} catch (Exception e) {
			e.printStackTrace();
		}

		return null;
	}

}
